class Solution {
public:
    vector<int> multiply(const vector<int>& A) {
        if(A.empty())
            return vector<int>();
        int n=A.size();
        vector<int> res(n,1);
        for(int i=1;i<n;i++)
            res[i]=res[i-1]*A[i-1];
        int temp=1;
        for(int i=n-2;i>=0;i--){
            temp=temp*A[i+1];
            res[i]=res[i]*temp;
        }
        return res;
    }
};